package com.yowasa.xiuxian.engine.battle.buff;

import com.yowasa.xiuxian.annoations.Buff;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.TempUserBattle;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;

@Buff(name="孤影亡身")
public class GuYingWangShenBuff implements BuffInterface {
    @Autowired
    private BattleHelper battleHelper;
    @Override
    public void effectBattleInfo(BuffContent content, TempUserBattle userBattle) {
        userBattle.setAtk((int) (userBattle.getAtk() * 1.05));
    }

    //回合开始时额外结算
    @Override
    public void beforeBuffAction(UserBattleContent first, UserBattleContent second, BattleContent content) {
        BuffContent buff = first.getBuff().get("孤影亡身");
        if (buff.getNum() >= 5 ){
            first.getBuff().get("孤影亡身").setNum(0);
            first.getBuff().get("孤影亡身").setDuration(0);
            int immAtk = first.getBattleInfo().getAtk();
            int dmg = battleHelper.calImm(immAtk, second.getBattleInfo().getImm());
            second.getBattleInfo().setChp(second.getBattleInfo().getChp() - dmg);
            content.getMsgLog().add(second.getUserBO().getName() + "因孤影亡身失去了" + dmg + "点血");
        }
    }
}
